package com.example.websockettest.webSocket.utils;

import java.security.SecureRandom;

/**
 * 代码中会用到的通用工具类
 *
 */
public class Utils {

    private static final String BASIC = "123456789qwertyuiopasdfghjklzxcvbnm";

    /**
     * 生成六位随机字符串
     * */
    public static String random(){
        char[] basicArray = BASIC.toCharArray();
        SecureRandom random = new SecureRandom();
        char[] result = new char[6];
        for (int i = 0; i < result.length; i++) {
            int index = random.nextInt(100) % (basicArray.length);
            result[i] = basicArray[index];
        }
        return new String(result);
    }


}
